﻿//-----------------------------------------------------------------------
// <copyright file="Copyright.cs" author="Michael Herndon">
//     Copyright (c) Company.  All rights reserved.
// </copyright>
//-----------------------------------------------------------------------

namespace Amplify.CodeDom
{
	using System;
	using System.CodeDom;
	using System.Collections.Generic;
	using System.Linq;
	using System.Text;

	public static partial class Mixin
	{

		public static CodeFieldReferenceExpression Field(this CodeVariableReferenceExpression unit, string fieldname)
		{
			CodeFieldReferenceExpression field = new CodeFieldReferenceExpression(unit, fieldname);
			return field;
		}

		public static CodeAssignStatement Is(this CodeFieldReferenceExpression unit, CodeExpression right)
		{
			return new CodeAssignStatement(unit, right);
		}

		public static CodeAssignStatement IsNewObject(this CodeFieldReferenceExpression unit, Type type, IEnumerable<CodeExpression> parameters)
		{
			return new CodeAssignStatement(unit, new CodeObjectCreateExpression(type, parameters.ToArray()));
		}

		public static CodeAssignStatement IsNewObject(this CodeFieldReferenceExpression unit, string type, IEnumerable<CodeExpression> parameters)
		{
			return new CodeAssignStatement(unit, new CodeObjectCreateExpression(type, parameters.ToArray()));
		}

		public static CodeAssignStatement IsNewObject(this CodeFieldReferenceExpression unit, CodeTypeReference type, IEnumerable<CodeExpression> parameters)
		{
			return new CodeAssignStatement(unit, new CodeObjectCreateExpression(type, parameters.ToArray()));
		}


		public static CodeAssignStatement IsNewObject(this CodePropertyReferenceExpression unit, Type type, IEnumerable<CodeExpression> parameters)
		{
			return new CodeAssignStatement(unit, new CodeObjectCreateExpression(type, parameters.ToArray()));
		}

		public static CodeAssignStatement IsNewObject(this CodePropertyReferenceExpression unit, string type, IEnumerable<CodeExpression> parameters)
		{
			return new CodeAssignStatement(unit, new CodeObjectCreateExpression(type, parameters.ToArray()));
		}

		public static CodeAssignStatement IsNewObject(this CodePropertyReferenceExpression unit, CodeTypeReference type, IEnumerable<CodeExpression> parameters)
		{
			return new CodeAssignStatement(unit, new CodeObjectCreateExpression(type, parameters.ToArray()));
		}

		public static CodeMethodReferenceExpression Method(this CodeVariableReferenceExpression unit, string methodname)
		{
			CodeMethodReferenceExpression method = new CodeMethodReferenceExpression(unit, methodname);
			return method;
		}
	}


	public  class Var : CodeVariableReferenceExpression
	{
		public Var() { }

		public Var(string variablename) : base(variablename) { }


	}
}
